﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IBLL;

namespace BLL
{
    public class AlbumBLL:IAlbumBLL
    {
        public List<Model.Album> getAlbumLists(int userId)
        {
            List<Model.Album> albumlist = new List<Model.Album>();
            DAL.AlbumDAL albumDal = (DAL.AlbumDAL)DALFAC.DataAccess.CreateAlbum();
            if (null != albumDal)
            {
                albumlist = albumDal.GetList(userId);
            }
            return albumlist;
        }


        public bool createAlbum(Model.Album album)
        {
            bool validator = false;
            DAL.AlbumDAL albumDal = (DAL.AlbumDAL)DALFAC.DataAccess.CreateAlbum();
            if (null != albumDal)
            {
                if (!albumDal.nameDuplicate(album.getAB_userId(), album.getAB_albumName())) 
                {
                    validator = albumDal.Add(album);
                }
            }
            return validator;
        }

        //
        public bool modifyAlbum(Model.Album album)
        {
            bool modifier = false;
            DAL.AlbumDAL albumDal = (DAL.AlbumDAL)DALFAC.DataAccess.CreateAlbum();
            if (null != albumDal)
            {
                modifier = albumDal.Update(album);                
            }

            return modifier;
        }

        public bool deleteAlbum(int albumId)
        {
            bool validator = false;
            DAL.AlbumDAL albumDal = (DAL.AlbumDAL)DALFAC.DataAccess.CreateAlbum();
            if (null != albumDal)
            {
                validator = albumDal.albumDelete(albumId);  
            }
            return validator;
        }

    }
}
